combobox: Use element names
authorMatthias Clasen <mclasen@redhat.com>
Mon, 2 Nov 2015 18:15:05 +0000 (13:15 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 2 Nov 2015 18:56:25 +0000 (13:56 -0500)
Use combobox as the element name for the main CSS nodes of
GtkComboBox and GtkComboBoxText. Add the .combo style class
to the button and entry. in a GtkComboBox or GtkComboBoxText.

gtk/gtkcombobox.c
gtk/ui/gtkcombobox.ui

index 39339e0948354d38bd5d1e75f8784d0a3541f21e..008cd3795dc26ecfea2cbae066586553ca7c02f1 100644 (file)
  * can be a bit overwhelming. In this case, #GtkComboBoxText offers a
  * simple alternative. Both GtkComboBox and #GtkComboBoxText can contain
  * an entry.
+ *
+ * # CSS nodes
+ *
+ * GtkComboBox has a single CSS node with name combobox. It adds the
+ * .combo style class to the button (and entry) that it contains.
  */
 
 
@@ -1066,6 +1071,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_button_toggled);
 
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COMBO_BOX_ACCESSIBLE);
+  gtk_widget_class_set_css_name (widget_class, "combobox");
 }
 
 static void
@@ -1094,6 +1100,7 @@ static void
 gtk_combo_box_init (GtkComboBox *combo_box)
 {
   GtkComboBoxPrivate *priv;
+  GtkStyleContext *context;
 
   combo_box->priv = gtk_combo_box_get_instance_private (combo_box);
   priv = combo_box->priv;
@@ -1123,6 +1130,10 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   gtk_widget_init_template (GTK_WIDGET (combo_box));
 
   gtk_widget_add_events (priv->button, GDK_SCROLL_MASK);
+
+  context = gtk_widget_get_style_context (priv->button);
+  gtk_style_context_remove_class (context, "toggle");
+  gtk_style_context_add_class (context, "combo");
 }
 
 static void
@@ -4400,8 +4411,11 @@ gtk_combo_box_constructed (GObject *object)
       gtk_widget_show (entry);
       gtk_container_add (GTK_CONTAINER (combo_box), entry);
 
+      context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+      gtk_style_context_add_class (context, "combo");
+
       context = gtk_widget_get_style_context (GTK_WIDGET (combo_box));
-      gtk_style_context_add_class (context, GTK_STYLE_CLASS_COMBOBOX_ENTRY);
+      gtk_style_context_add_class (context, "linked");
 
       priv->text_renderer = gtk_cell_renderer_text_new ();
       gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box),
index 90ae27b38621e624e25ca0abc20f6346db3fbd53..ad4d5bd2c34f304ffbe5667d3bfd5a284200b8af 100644 (file)
@@ -6,9 +6,6 @@
       <object class="GtkToggleButton" id="button">
         <property name="visible">1</property>
         <signal name="toggled" handler="gtk_combo_box_button_toggled" swapped="no"/>
-        <style>
-          <class name="the-button-in-the-combobox"/>
-        </style>
         <child>
           <object class="GtkBox">
             <property name="visible">1</property>